const koa = require('koa')
const koaBody = require('koa-body')
const app = new koa()

const main = ctx => {
  const body = ctx.request.body
  if (!body.name) {
    ctx.throw(400)
  }
  ctx.response.body = { name: body.name }
}
app.use(koaBody())
app.use(main)

app.listen(3000)
